from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
from mail.settings import SECRET_KEY

def generate_save_token(openid):
    s = Serializer(secret_key= SECRET_KEY,expires_in=3600)

    data = s.dumps({'openid':openid})
    return data


def check_save_user_token(access_token):
    s = Serializer(secret_key=SECRET_KEY, expires_in=3600)

    data = s.loads(access_token)
    return data.get('openid')